package com.mty.cc.service.impl;


import com.mty.cc.mapper.UserMapper;
import com.mty.cc.po.User;
import com.mty.cc.service.UserService;
import com.mty.cc.util.uuid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired(required=false)
    private UserMapper userMapper;

    /*
     * @description: 添加方法
     * @author: mty
     */
    @Override
    public void add(User user) {
        user.setId(uuid.getRandomIdByUUID());
        userMapper.add(user);
    }

    /*
     * @description: 更新
     * @author: mty
     */
    @Override
    public void update(User user) {
        userMapper.update(user);
    }

    /*
     * @description: 按照ID删除
     * @author: mty
     */
    @Override
    public void deleteById(String id) {
        userMapper.deleteById(id);
    }

    /*
     * @description: 查询全部
     * @author: mty
     */
    @Override
    public List<User> queryByAll() {
        return userMapper.queryByAll();
    }

    /*
     * @description: 查询
     * @author: mty
     */
    @Override
    public List<User> queryByOne(String username,String password) {
        return userMapper.queryByOne(username,password);
    }

    /*
     * @description: 根据ID查询
     * @author: mty
     */
    @Override
    public User queryById(String id) {
        return userMapper.queryById(id);
    }
}

